
import java.util.HashMap;
import java.util.Map;

public class Solution {
    public int findMostTrading(int[] tradingList) {
        // 创建一个哈希表用于存储交易金额及其出现次数
        Map<Integer, Integer> freqMap = new HashMap<>();
        int maxFreq = 0;
        int mostFrequentAmount = Integer.MAX_VALUE;

        for (int amount : tradingList) {
            // 更新交易金额的出现次数
            freqMap.put(amount, freqMap.getOrDefault(amount, 0) + 1);
            // 更新最大出现次数
            int freq = freqMap.get(amount);
            if (freq > maxFreq || (freq == maxFreq && amount < mostFrequentAmount)) {
                maxFreq = freq;
                mostFrequentAmount = amount;
            }
        }

        return mostFrequentAmount;
    }


}
